<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<title>std::seed_seq::generate - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../../../common/favicon.ico">
<link rel="stylesheet" href="../../../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/numeric/random/seed_seq/generate","wgTitle":"cpp/numeric/random/seed seq/generate","wgCurRevisionId":135849,"wgArticleId":8938,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/numeric/random/seed_seq/generate","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1,"gadget-MathJax":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_numeric_random_seed_seq_generate skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::seed_seq::</span>generate</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../../../cpp.html" title="cpp">cpp</a>‎ | <a href="../../../numeric.html" title="cpp/numeric">numeric</a>‎ | <a href="../../random.html" title="cpp/numeric/random">random</a>‎ | <a href="../seed_seq.html" title="cpp/numeric/random/seed seq">seed seq</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../../../compiler_support.html" title="cpp/compiler support"> Compiler support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../freestanding.html" title="cpp/freestanding"> Freestanding and hosted</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../language.html" title="cpp/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../header.html" title="cpp/header"> Standard library headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../named_req.html" title="cpp/named req"> Named requirements </a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../feature_test.html" title="cpp/feature test"> Feature test macros </a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../utility.html#Language_support" title="cpp/utility"> Language support library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../concepts.html" title="cpp/concepts"> Concepts library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../meta.html" title="cpp/meta"> Metaprogramming library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../error.html" title="cpp/error"> Diagnostics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../utility.html" title="cpp/utility"> General utilities library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../string.html" title="cpp/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../container.html" title="cpp/container"> Containers library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../iterator.html" title="cpp/iterator"> Iterators library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../ranges.html" title="cpp/ranges"> Ranges library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../algorithm.html" title="cpp/algorithm"> Algorithms library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../numeric.html" title="cpp/numeric"> Numerics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../locale.html" title="cpp/locale"> Localizations library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../io.html" title="cpp/io"> Input/output library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../filesystem.html" title="cpp/filesystem"> Filesystem library</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../regex.html" title="cpp/regex"> Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../thread.html" title="cpp/thread"> Concurrency support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../experimental.html" title="cpp/experimental"> Technical specifications</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../symbol_index.html" title="cpp/symbol index"> Symbols index</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../../links/libs.html" title="cpp/links/libs"> External libraries</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../../numeric.html" title="cpp/numeric"> Numerics library</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../../math.html" title="cpp/numeric/math">Common mathematical functions</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../special_functions.html" title="cpp/numeric/special functions">Mathematical special functions</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../constants.html" title="cpp/numeric/constants">Mathematical constants</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../fenv.html" title="cpp/numeric/fenv">Floating-point environment</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../complex.html" title="cpp/numeric/complex">Complex numbers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../valarray.html" title="cpp/numeric/valarray">Numeric arrays</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../random.html" title="cpp/numeric/random">Pseudo-random number generation</a> </td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../../../numeric.html#Factor_operations" title="cpp/numeric">Factor operations</a> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../gcd.html" title="cpp/numeric/gcd"><span class="t-lines"><span>gcd</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../lcm.html" title="cpp/numeric/lcm"><span class="t-lines"><span>lcm</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../../../numeric.html#Interpolation_operations" title="cpp/numeric">Interpolations</a> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../midpoint.html" title="cpp/numeric/midpoint"><span class="t-lines"><span>midpoint</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../lerp.html" title="cpp/numeric/lerp"><span class="t-lines"><span>lerp</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../../../numeric.html#Numeric_operations" title="cpp/numeric">Generic numeric operations</a> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/iota.html" title="cpp/algorithm/iota"><span class="t-lines"><span>iota</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/ranges/iota.html" title="cpp/algorithm/ranges/iota"><span class="t-lines"><span>ranges::iota</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/accumulate.html" title="cpp/algorithm/accumulate"><span class="t-lines"><span>accumulate</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/inner_product.html" title="cpp/algorithm/inner product"><span class="t-lines"><span>inner_product</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/adjacent_difference.html" title="cpp/algorithm/adjacent difference"><span class="t-lines"><span>adjacent_difference</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/partial_sum.html" title="cpp/algorithm/partial sum"><span class="t-lines"><span>partial_sum</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/reduce.html" title="cpp/algorithm/reduce"><span class="t-lines"><span>reduce</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/transform_reduce.html" title="cpp/algorithm/transform reduce"><span class="t-lines"><span>transform_reduce</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/inclusive_scan.html" title="cpp/algorithm/inclusive scan"><span class="t-lines"><span>inclusive_scan</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/exclusive_scan.html" title="cpp/algorithm/exclusive scan"><span class="t-lines"><span>exclusive_scan</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/transform_inclusive_scan.html" title="cpp/algorithm/transform inclusive scan"><span class="t-lines"><span>transform_inclusive_scan</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../algorithm/transform_exclusive_scan.html" title="cpp/algorithm/transform exclusive scan"><span class="t-lines"><span>transform_exclusive_scan</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../../../numeric.html#Bit_manipulation_.28since_C.2B.2B20.29" title="cpp/numeric">Bit operations</a></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../bit_cast.html" title="cpp/numeric/bit cast"><span class="t-lines"><span>bit_cast</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../byteswap.html" title="cpp/numeric/byteswap"><span class="t-lines"><span>byteswap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../has_single_bit.html" title="cpp/numeric/has single bit"><span class="t-lines"><span>has_single_bit</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../bit_ceil.html" title="cpp/numeric/bit ceil"><span class="t-lines"><span>bit_ceil</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../bit_floor.html" title="cpp/numeric/bit floor"><span class="t-lines"><span>bit_floor</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../bit_width.html" title="cpp/numeric/bit width"><span class="t-lines"><span>bit_width</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../rotl.html" title="cpp/numeric/rotl"><span class="t-lines"><span>rotl</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../rotr.html" title="cpp/numeric/rotr"><span class="t-lines"><span>rotr</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../countl_zero.html" title="cpp/numeric/countl zero"><span class="t-lines"><span>countl_zero</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../countl_one.html" title="cpp/numeric/countl one"><span class="t-lines"><span>countl_one</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../countr_zero.html" title="cpp/numeric/countr zero"><span class="t-lines"><span>countr_zero</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../countr_one.html" title="cpp/numeric/countr one"><span class="t-lines"><span>countr_one</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../popcount.html" title="cpp/numeric/popcount"><span class="t-lines"><span>popcount</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../../types/endian.html" title="cpp/types/endian"><span class="t-lines"><span>endian</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../random.html" title="cpp/numeric/random">Pseudo-random number generation</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> Uniform random bit generators</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../UniformRandomBitGenerator.html" title="cpp/numeric/random/uniform random bit generator"><span class="t-lines"><span>uniform_random_bit_generator</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Engines and engine adaptors</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../linear_congruential_engine.html" title="cpp/numeric/random/linear congruential engine"><span class="t-lines"><span>linear_congruential_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../mersenne_twister_engine.html" title="cpp/numeric/random/mersenne twister engine"><span class="t-lines"><span>mersenne_twister_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../subtract_with_carry_engine.html" title="cpp/numeric/random/subtract with carry engine"><span class="t-lines"><span>subtract_with_carry_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../discard_block_engine.html" title="cpp/numeric/random/discard block engine"><span class="t-lines"><span>discard_block_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../independent_bits_engine.html" title="cpp/numeric/random/independent bits engine"><span class="t-lines"><span>independent_bits_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../shuffle_order_engine.html" title="cpp/numeric/random/shuffle order engine"><span class="t-lines"><span>shuffle_order_engine</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Non-deterministic generator</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../random_device.html" title="cpp/numeric/random/random device"><span class="t-lines"><span>random_device</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Distributions</td></tr>
<tr class="t-nv-h2"><td colspan="5"> Uniform distributions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uniform_int_distribution.html" title="cpp/numeric/random/uniform int distribution"><span class="t-lines"><span>uniform_int_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../uniform_real_distribution.html" title="cpp/numeric/random/uniform real distribution"><span class="t-lines"><span>uniform_real_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../generate_canonical.html" title="cpp/numeric/random/generate canonical"><span class="t-lines"><span>generate_canonical</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Bernoulli distributions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../bernoulli_distribution.html" title="cpp/numeric/random/bernoulli distribution"><span class="t-lines"><span>bernoulli_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../binomial_distribution.html" title="cpp/numeric/random/binomial distribution"><span class="t-lines"><span>binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../negative_binomial_distribution.html" title="cpp/numeric/random/negative binomial distribution"><span class="t-lines"><span>negative_binomial_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../geometric_distribution.html" title="cpp/numeric/random/geometric distribution"><span class="t-lines"><span>geometric_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Poisson distributions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../poisson_distribution.html" title="cpp/numeric/random/poisson distribution"><span class="t-lines"><span>poisson_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../exponential_distribution.html" title="cpp/numeric/random/exponential distribution"><span class="t-lines"><span>exponential_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../gamma_distribution.html" title="cpp/numeric/random/gamma distribution"><span class="t-lines"><span>gamma_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../weibull_distribution.html" title="cpp/numeric/random/weibull distribution"><span class="t-lines"><span>weibull_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../extreme_value_distribution.html" title="cpp/numeric/random/extreme value distribution"><span class="t-lines"><span>extreme_value_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Normal distributions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../normal_distribution.html" title="cpp/numeric/random/normal distribution"><span class="t-lines"><span>normal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../lognormal_distribution.html" title="cpp/numeric/random/lognormal distribution"><span class="t-lines"><span>lognormal_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../chi_squared_distribution.html" title="cpp/numeric/random/chi squared distribution"><span class="t-lines"><span>chi_squared_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../cauchy_distribution.html" title="cpp/numeric/random/cauchy distribution"><span class="t-lines"><span>cauchy_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../fisher_f_distribution.html" title="cpp/numeric/random/fisher f distribution"><span class="t-lines"><span>fisher_f_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../student_t_distribution.html" title="cpp/numeric/random/student t distribution"><span class="t-lines"><span>student_t_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Sampling distributions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../discrete_distribution.html" title="cpp/numeric/random/discrete distribution"><span class="t-lines"><span>discrete_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../piecewise_constant_distribution.html" title="cpp/numeric/random/piecewise constant distribution"><span class="t-lines"><span>piecewise_constant_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../piecewise_linear_distribution.html" title="cpp/numeric/random/piecewise linear distribution"><span class="t-lines"><span>piecewise_linear_distribution</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Seed Sequences</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../seed_seq.html" title="cpp/numeric/random/seed seq"><span class="t-lines"><span>seed_seq</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> C library</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../rand.html" title="cpp/numeric/random/rand"><span class="t-lines"><span>rand</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../srand.html" title="cpp/numeric/random/srand"><span class="t-lines"><span>srand</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../RAND_MAX.html" title="cpp/numeric/random/RAND MAX"><span class="t-lines"><span>RAND_MAX</span></span></a></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../seed_seq.html" title="cpp/numeric/random/seed seq"><tt>std::seed_seq</tt></a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> Member functions</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="seed_seq.html" title="cpp/numeric/random/seed seq/seed seq"><span class="t-lines"><span>seed_seq::seed_seq</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>seed_seq::generate</span></span></strong></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="size.html" title="cpp/numeric/random/seed seq/size"><span class="t-lines"><span>seed_seq::size</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="param.html" title="cpp/numeric/random/seed seq/param"><span class="t-lines"><span>seed_seq::param</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx11">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> RandomIt <span class="sy1">&gt;</span><br>
<span class="kw4">void</span> generate<span class="br0">(</span> RandomIt begin, RandomIt end <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx11">(since C++11)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>Fills the range <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">[</span>begin, end<span class="br0">)</span></span></span> with unsigned integer values <code>i</code>, <span class="texhtml" style="white-space: nowrap;">0 ≤ i &lt; 2<span class="t-su">32<br></span></span>, based on the data originally provided in the constructor of this <code>seed_seq</code>. The produced values are distributed over the entire 32-bit range even if the initial values were strongly biased.
</p><p>The following algorithm is used (adapted from the initialization sequence of the Mersenne Twister generator by <a rel="nofollow" class="external text" href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">Makoto Matsumoto and Takuji Nishimura</a>, incorporating the improvements made by <a rel="nofollow" class="external text" href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/M062821.pdf">Mutsuo Saito in 2007</a>)
</p>
<ul><li> If <span class="t-c"><span class="mw-geshi cpp source-cpp">begin <span class="sy1">==</span> end</span></span>, do nothing. Otherwise,
</li></ul>
<ul><li> First, set each element of the output range to the value <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu12">0x8b8b8b8b</span></span></span>
</li></ul>
<ul><li> Transform the elements of the output range according to the following algorithm:
</li></ul>
<p>For <span class="t-c"><span class="mw-geshi cpp source-cpp">k <span class="sy1">=</span> <span class="nu0">0</span>,..., m<span class="sy2">-</span><span class="nu0">1</span></span></span><br>
</p><p>where <span class="t-c"><span class="mw-geshi cpp source-cpp">m<span class="sy1">=</span>max<span class="br0">(</span>s<span class="sy2">+</span><span class="nu0">1</span>, n<span class="br0">)</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">n<span class="sy1">=</span>end<span class="sy2">-</span>begin</span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">s<span class="sy1">=</span>v.<span class="me1">size</span><span class="br0">(</span><span class="br0">)</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">v</span></span> is the private container holding the values originally provided by the constructor of this <code>seed_seq</code> object,
</p>
<ol><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="sy2">+</span>p<span class="br0">]</span> <span class="sy2">+</span><span class="sy1">=</span> r1</span></span>
</li><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="sy2">+</span>q<span class="br0">]</span> <span class="sy2">+</span><span class="sy1">=</span> r2</span></span>
</li><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="br0">]</span> <span class="sy1">=</span> r2</span></span>,
</li></ol>
<p>where <span class="t-c"><span class="mw-geshi cpp source-cpp">p<span class="sy1">=</span><span class="br0">(</span>n<span class="sy2">-</span>t<span class="br0">)</span><span class="sy2">/</span><span class="nu0">2</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">q<span class="sy1">=</span>p<span class="sy2">+</span>t</span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">t<span class="sy1">=</span><span class="br0">(</span>n <span class="sy1">&gt;=</span> <span class="nu0">623</span><span class="br0">)</span> <span class="sy4">?</span> <span class="nu0">11</span> <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&gt;=</span> <span class="nu0">68</span><span class="br0">)</span> <span class="sy4">?</span> <span class="nu0">7</span> <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&gt;=</span> <span class="nu0">39</span><span class="br0">)</span> <span class="sy4">?</span> <span class="nu0">5</span> <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&gt;=</span> <span class="nu0">7</span><span class="br0">)</span> <span class="sy4">?</span> <span class="nu0">3</span> <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy2">-</span> <span class="nu0">1</span><span class="br0">)</span> <span class="sy2">/</span> <span class="nu0">2</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">r1<span class="sy1">=</span><span class="nu0">1664525</span> <span class="sy2">*</span> T<span class="br0">(</span>begin<span class="br0">[</span>k<span class="br0">]</span><span class="sy3">^</span>begin<span class="br0">[</span>k<span class="sy2">+</span>p<span class="br0">]</span><span class="sy3">^</span>begin<span class="br0">[</span>k−<span class="nu0">1</span><span class="br0">]</span><span class="br0">)</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">T<span class="br0">(</span>x<span class="br0">)</span> <span class="sy1">=</span> x <span class="sy3">^</span> <span class="br0">(</span>x <span class="sy1">&gt;&gt;</span> <span class="nu0">27</span><span class="br0">)</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">r2<span class="sy1">=</span>r1<span class="sy2">+</span>s</span></span> if <span class="t-c"><span class="mw-geshi cpp source-cpp">k<span class="sy1">==</span><span class="nu0">0</span></span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">r2<span class="sy1">=</span>r1 <span class="sy2">+</span> k<span class="sy2">%</span>n <span class="sy2">+</span> v<span class="br0">[</span>k<span class="sy2">-</span><span class="nu0">1</span><span class="br0">]</span></span></span> if <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu0">0</span><span class="sy1">&lt;</span>k<span class="sy1">&lt;=</span>s</span></span>, <span class="t-c"><span class="mw-geshi cpp source-cpp">r2<span class="sy1">=</span>r1 <span class="sy2">+</span> k<span class="sy2">%</span>n</span></span> if <span class="t-c"><span class="mw-geshi cpp source-cpp">k<span class="sy1">&gt;</span>s</span></span>.
</p><p>For <span class="t-c"><span class="mw-geshi cpp source-cpp">k <span class="sy1">=</span> m,..., m<span class="sy2">+</span>n<span class="sy2">-</span><span class="nu0">1</span></span></span>, 
</p>
<ol><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="sy2">+</span>p<span class="br0">]</span> <span class="sy3">^</span><span class="sy1">=</span> r3</span></span>
</li><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="sy2">+</span>q<span class="br0">]</span> <span class="sy3">^</span><span class="sy1">=</span> r4</span></span>
</li><li> <span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>k<span class="br0">]</span><span class="sy1">=</span>r4</span></span>
</li></ol>
<p>where <span class="t-c"><span class="mw-geshi cpp source-cpp">r3 <span class="sy1">=</span> <span class="nu0">1566083941</span> <span class="sy2">*</span> T<span class="br0">(</span>begin<span class="br0">[</span>k<span class="br0">]</span><span class="sy2">+</span>begin<span class="br0">[</span>k<span class="sy2">+</span>p<span class="br0">]</span><span class="sy2">+</span>begin<span class="br0">[</span>k<span class="sy2">-</span><span class="nu0">1</span><span class="br0">]</span><span class="br0">)</span></span></span><br>
and <span class="t-c"><span class="mw-geshi cpp source-cpp">r4<span class="sy1">=</span>r3 <span class="sy2">-</span> k<span class="sy2">%</span>n</span></span>
</p><p>where all calculations are performed <span class="texhtml" style="white-space: nowrap;">modulo 2<span class="t-su">32<br></span></span> and where the indexing of the output range (<span class="t-c"><span class="mw-geshi cpp source-cpp">begin<span class="br0">[</span>x<span class="br0">]</span></span></span>) is taken <span class="texhtml" style="white-space: nowrap;">modulo n</span>.
</p>
<h3><span class="mw-headline" id="Parameters">Parameters</span></h3>
<table class="t-par-begin">


<tr class="t-par">
<td>  begin, end
</td>
<td> -
</td>
<td>  mutable random-access iterators whose <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../../iterator/iterator_traits.html"><span class="kw653">std::<span class="me2">iterator_traits</span></span></a><span class="sy1">&lt;&gt;</span><span class="sy4">::</span><span class="me2">value_type</span></span></span> is an unsigned integer type suitable for storing 32-bit values
</td></tr>
<tr class="t-par-hitem">
<td colspan="3"> Type requirements
</td></tr>
<tr class="t-par-req">
<td colspan="3"> -<div class="spacer"></div><code>RandomIt</code> must meet the requirements of <a href="../../../named_req/RandomAccessIterator.html" title="cpp/named req/RandomAccessIterator"><span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">LegacyRandomAccessIterator</span></a>.
</td></tr></table>
<h3><span class="mw-headline" id="Return_value">Return value</span></h3>
<p>none, the results are written to the <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">[</span>begin, end<span class="br0">)</span></span></span> range.
</p>
<h3><span class="mw-headline" id="Exceptions">Exceptions</span></h3>
<p>Only throws if the operations on <code>begin</code> and <code>end</code> throw.
</p>
<h3><span class="mw-headline" id="Example">Example</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;algorithm&gt;</span>
<span class="co2">#include &lt;cassert&gt;</span>
<span class="co2">#include &lt;cstdint&gt;</span>
<span class="co2">#include &lt;iostream&gt;</span>
<span class="co2">#include &lt;random&gt;</span>
 
<span class="co1">// Prototyping the main part of std::seed_seq...</span>
<span class="kw1">struct</span> seed_seq <span class="br0">{</span>
    <a href="../../../container/vector.html"><span class="kw1272">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a><span class="sy1">&gt;</span> v<span class="sy4">;</span>
 
    seed_seq<span class="br0">(</span><a href="../../../utility/initializer_list.html"><span class="kw961">std::<span class="me2">initializer_list</span></span></a><span class="sy1">&lt;</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a><span class="sy1">&gt;</span> <span class="kw4">const</span> il<span class="br0">)</span> <span class="sy4">:</span> v<span class="br0">{</span>il<span class="br0">}</span> <span class="br0">{</span><span class="br0">}</span>
 
    <span class="kw1">template</span> <span class="sy1">&lt;</span><span class="kw1">typename</span> RandomIt<span class="sy1">&gt;</span>
    <span class="kw4">void</span> generate<span class="br0">(</span>RandomIt first, RandomIt last<span class="br0">)</span> <span class="br0">{</span>
        <span class="kw1">if</span> <span class="br0">(</span>first <span class="sy1">==</span> last<span class="br0">)</span>
            <span class="kw1">return</span><span class="sy4">;</span>
        <span class="co1">//</span>
        <span class="co1">// Assuming v = {1,2,3,4,5} and distance(first, last) == 10.</span>
        <span class="co1">//</span>
        <span class="co1">// Step 1: fill with 0x8b8b8b8b</span>
        <span class="co1">// seeds = {2341178251, 2341178251, 2341178251, 2341178251, 2341178251,</span>
        <span class="co1">//          2341178251, 2341178251, 2341178251, 2341178251, 2341178251 }</span>
        <span class="co1">//</span>
        <a href="../../../algorithm/fill.html"><span class="kw1591">std::<span class="me2">fill</span></span></a><span class="br0">(</span>first, last, <span class="nu12">0x8b8b8b8b</span><span class="br0">)</span><span class="sy4">;</span>
        <span class="co1">//</span>
        <span class="co1">// Step 2:</span>
        <span class="co1">// n = 10, s = 5, t = 3, p = 3, q = 6, m = 10</span>
        <span class="co1">//</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> n <span class="sy1">=</span> last <span class="sy2">-</span> first<span class="sy4">;</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> s <span class="sy1">=</span> v.<span class="me1">size</span><span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> t <span class="sy1">=</span> <span class="br0">(</span>n <span class="sy1">&lt;</span> <span class="nu0">7</span><span class="br0">)</span> <span class="sy4">?</span> <span class="br0">(</span>n <span class="sy2">-</span> <span class="nu0">1</span><span class="br0">)</span> <span class="sy2">/</span> <span class="nu0">2</span>
                              <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&lt;</span> <span class="nu0">39</span><span class="br0">)</span> <span class="sy4">?</span> <span class="nu0">3</span>
                              <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&lt;</span> <span class="nu0">68</span><span class="br0">)</span>  <span class="sy4">?</span> <span class="nu0">5</span>
                              <span class="sy4">:</span> <span class="br0">(</span>n <span class="sy1">&lt;</span> <span class="nu0">623</span><span class="br0">)</span>  <span class="sy4">?</span> <span class="nu0">7</span>
                              <span class="sy4">:</span> <span class="nu0">11</span><span class="sy4">;</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> p <span class="sy1">=</span> <span class="br0">(</span>n <span class="sy2">-</span> t<span class="br0">)</span> <span class="sy2">/</span> <span class="nu0">2</span><span class="sy4">;</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> q <span class="sy1">=</span> p <span class="sy2">+</span> t<span class="sy4">;</span>
        <span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> m <span class="sy1">=</span> <a href="../../../algorithm/max.html"><span class="kw1644">std::<span class="me2">max</span></span></a><span class="br0">(</span>s <span class="sy2">+</span> <span class="nu0">1</span>, n<span class="br0">)</span><span class="sy4">;</span>
        <span class="co1">//</span>
        <span class="co1">// First iteration, k = 0; r1 = 1371501266, r2 = 1371501271</span>
        <span class="co1">//</span>
        <span class="co1">// seeds = {1371501271, 2341178251, 2341178251, 3712679517, 2341178251,</span>
        <span class="co1">//          2341178251, 3712679522, 2341178251, 2341178251, 2341178251 }</span>
        <span class="co1">//</span>
        <span class="co1">// Iterations from k = 1 to k = 5 (r2 = r1 + k%n + v[k-1])</span>
        <span class="co1">//</span>
        <span class="co1">// r1 = 2786190137, 3204727651, 4173325571, 1979226628, 401983366</span>
        <span class="co1">// r2 = 2786190139, 3204727655, 4173325577, 1979226636, 401983376</span>
        <span class="co1">//</span>
        <span class="co1">// seeds = {3350727907, 3188173515, 3204727655, 4173325577, 1979226636,</span>
        <span class="co1">//           401983376, 3591037797, 2811627722, 1652921976, 2219536532 }</span>
        <span class="co1">//</span>
        <span class="co1">// Iterations from k = 6 to k = 9 (r2 = r1 + k%n)</span>
        <span class="co1">//</span>
        <span class="co1">// r1 = 2718637909, 1378394210, 2297813071, 1608643617</span>
        <span class="co1">// r2 = 2718637915, 1378394217, 2297813079, 1608643626</span>
        <span class="co1">//</span>
        <span class="co1">// seeds = { 434154821, 1191019290, 3237041891, 1256752498, 4277039715,</span>
        <span class="co1">//          2010627002, 2718637915, 1378394217, 2297813079, 1608643626 }</span>
        <span class="co1">//</span>
        <span class="kw4">auto</span> begin_mod <span class="sy1">=</span> <span class="br0">[</span>first, n<span class="br0">]</span><span class="br0">(</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> u<span class="br0">)</span> <span class="sy2">-</span><span class="sy1">&gt;</span> decltype<span class="br0">(</span><span class="sy2">*</span>first<span class="br0">)</span><span class="sy3">&amp;</span> <span class="br0">{</span>
            <span class="kw1">return</span> first<span class="br0">[</span>u <span class="sy2">%</span> n<span class="br0">]</span><span class="sy4">;</span> <span class="co1">// i.e. begin[x] is taken modulo n</span>
        <span class="br0">}</span><span class="sy4">;</span>
        <span class="kw4">auto</span> T <span class="sy1">=</span> <span class="br0">[</span><span class="br0">]</span><span class="br0">(</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> x<span class="br0">)</span> <span class="br0">{</span> <span class="kw1">return</span> x <span class="sy3">^</span> <span class="br0">(</span>x <span class="sy1">&gt;&gt;</span> <span class="nu0">27</span><span class="br0">)</span><span class="sy4">;</span> <span class="br0">}</span><span class="sy4">;</span>
 
        <span class="kw1">for</span> <span class="br0">(</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> k <span class="sy1">=</span> <span class="nu0">0</span>, r1, r2<span class="sy4">;</span> k <span class="sy1">&lt;</span> m<span class="sy4">;</span> <span class="sy2">++</span>k<span class="br0">)</span> <span class="br0">{</span>
            r1 <span class="sy1">=</span> <span class="nu0">1664525</span> <span class="sy2">*</span> T<span class="br0">(</span>begin_mod<span class="br0">(</span>k<span class="br0">)</span> <span class="sy3">^</span> begin_mod<span class="br0">(</span>k <span class="sy2">+</span> p<span class="br0">)</span> <span class="sy3">^</span> begin_mod<span class="br0">(</span>k <span class="sy2">-</span> <span class="nu0">1</span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
            r2 <span class="sy1">=</span> <span class="br0">(</span>k <span class="sy1">==</span> <span class="nu0">0</span><span class="br0">)</span> <span class="sy4">?</span> r1 <span class="sy2">+</span> s
               <span class="sy4">:</span> <span class="br0">(</span>k <span class="sy1">&lt;=</span> s<span class="br0">)</span> <span class="sy4">?</span> r1 <span class="sy2">+</span> k <span class="sy2">%</span> n <span class="sy2">+</span> v<span class="br0">[</span>k <span class="sy2">-</span> <span class="nu0">1</span><span class="br0">]</span>
               <span class="sy4">:</span>            r1 <span class="sy2">+</span> k <span class="sy2">%</span> n<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k <span class="sy2">+</span> p<span class="br0">)</span> <span class="sy2">+</span><span class="sy1">=</span> r1<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k <span class="sy2">+</span> q<span class="br0">)</span> <span class="sy2">+</span><span class="sy1">=</span> r2<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k<span class="br0">)</span> <span class="sy1">=</span> r2<span class="sy4">;</span>
        <span class="br0">}</span>
        <span class="co1">//</span>
        <span class="co1">// Step 3</span>
        <span class="co1">// iterations from k = 10 to k = 19, using ^= to modify the output</span>
        <span class="co1">//</span>
        <span class="co1">// r1 = 1615303485, 3210438310, 893477041, 2884072672, 1918321961,</span>
        <span class="co1">// r2 = 1615303485, 3210438309, 893477039, 2884072669, 1918321957</span>
        <span class="co1">//</span>
        <span class="co1">// seeds = { 303093272, 3210438309,  893477039, 2884072669, 1918321957,</span>
        <span class="co1">//          1117182731, 1772877958, 2669970405, 3182737656, 4094066935 }</span>
        <span class="co1">//</span>
        <span class="co1">// r1 =  423054846, 46783064, 3904109085, 1534123446, 1495905687</span>
        <span class="co1">// r2 =  423054841, 46783058, 3904109078, 1534123438, 1495905678</span>
        <span class="co1">//</span>
        <span class="co1">// seeds = { 4204997637, 4246533866, 1856049002, 1129615051, 690460811,</span>
        <span class="co1">//           1075771511,   46783058, 3904109078, 1534123438, 1495905678 }</span>
        <span class="co1">//</span>
        <span class="kw1">for</span> <span class="br0">(</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> k <span class="sy1">=</span> m, r3, r4<span class="sy4">;</span> k <span class="sy1">&lt;</span> m <span class="sy2">+</span> n<span class="sy4">;</span> <span class="sy2">++</span>k<span class="br0">)</span> <span class="br0">{</span>
            r3 <span class="sy1">=</span> <span class="nu0">1566083941</span> <span class="sy2">*</span> T<span class="br0">(</span>begin_mod<span class="br0">(</span>k<span class="br0">)</span> <span class="sy2">+</span> begin_mod<span class="br0">(</span>k<span class="sy2">+</span>p<span class="br0">)</span> <span class="sy2">+</span> begin_mod<span class="br0">(</span>k<span class="sy2">-</span><span class="nu0">1</span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
            r4 <span class="sy1">=</span> r3 <span class="sy2">-</span> k<span class="sy2">%</span>n<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k<span class="sy2">+</span>p<span class="br0">)</span> <span class="sy3">^</span><span class="sy1">=</span> r3<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k<span class="sy2">+</span>q<span class="br0">)</span> <span class="sy3">^</span><span class="sy1">=</span> r4<span class="sy4">;</span>
            begin_mod<span class="br0">(</span>k<span class="br0">)</span> <span class="sy1">=</span> r4<span class="sy4">;</span>
        <span class="br0">}</span>
    <span class="br0">}</span>
<span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
 
    <span class="kw4">const</span> <span class="kw4">auto</span> input <span class="sy1">=</span> <a href="../../../utility/initializer_list.html"><span class="kw961">std::<span class="me2">initializer_list</span></span></a><span class="sy1">&lt;</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a><span class="sy1">&gt;</span><span class="br0">{</span><span class="nu0">1</span>,<span class="nu0">2</span>,<span class="nu0">3</span>,<span class="nu0">4</span>,<span class="nu0">5</span><span class="br0">}</span><span class="sy4">;</span>
    <span class="kw4">const</span> <span class="kw4">auto</span> output_size <span class="sy1">=</span> <span class="nu0">10</span><span class="sy4">;</span>
 
    <span class="co1">// using std version of seed_seq</span>
    <a href="../seed_seq.html"><span class="kw1504">std::<span class="me2">seed_seq</span></span></a> seq<span class="br0">(</span>input<span class="br0">)</span><span class="sy4">;</span>
    <a href="../../../container/vector.html"><span class="kw1272">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a><span class="sy1">&gt;</span> seeds<span class="br0">(</span>output_size<span class="br0">)</span><span class="sy4">;</span>
    seq.<span class="me1">generate</span><span class="br0">(</span>seeds.<span class="me1">begin</span><span class="br0">(</span><span class="br0">)</span>, seeds.<span class="me1">end</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
    <span class="kw1">for</span><span class="br0">(</span><span class="kw4">const</span> <a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a> n <span class="sy4">:</span> seeds<span class="br0">)</span> <span class="br0">{</span>
        <a href="../../../io/cout.html"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> n <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <span class="br0">}</span>
 
    <span class="co1">// using custom version of seed_seq</span>
    seed_seq seq2<span class="br0">(</span>input<span class="br0">)</span><span class="sy4">;</span>
    <a href="../../../container/vector.html"><span class="kw1272">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><a href="../../../types/integer.html"><span class="kw128">std::<span class="me2">uint32_t</span></span></a><span class="sy1">&gt;</span> seeds2<span class="br0">(</span>output_size<span class="br0">)</span><span class="sy4">;</span>
    seq2.<span class="me1">generate</span><span class="br0">(</span>seeds2.<span class="me1">begin</span><span class="br0">(</span><span class="br0">)</span>, seeds2.<span class="me1">end</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
 
    <a href="../../../error/assert.html"><span class="kw775">assert</span></a><span class="br0">(</span>seeds <span class="sy1">==</span> seeds2<span class="br0">)</span><span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>Output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">4204997637
4246533866
1856049002
1129615051
690460811
1075771511
46783058
3904109078
1534123438
1495905678</pre></div></div> 
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 6930/1000000
Preprocessor generated node count: 10259/1000000
Post‐expand include size: 207814/2097152 bytes
Template argument size: 52265/2097152 bytes
Highest expansion depth: 19/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:8938-0!*!0!!en!*!* and timestamp 20220410134817 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/random/seed_seq/generate&amp;oldid=135849">https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/random/seed_seq/generate&amp;oldid=135849</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>Navigation</h5>
            <ul><li><a href="https://en.cppreference.com/w/cpp/numeric/random/seed_seq/generate">Online version</a></li><li>Offline version retrieved 2022-07-30 14:05.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> This page was last modified on 28 November 2021, at 19:26.</li>
                                    <li id="footer-info-viewcount">This page has been accessed 15,761 times.</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler","ext.gadget.MathJax"], null, true);
}</script>
<script src="../../../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 3.244 secs. -->
	</body>
<!-- Cached 20220410134817 -->
</html>